export default {
	data() {
		return {
			mp: {
				statusBarHeight: 0, // 小程序状态栏高度
				navBarHeight: 0, // 小程序导航栏高度
				topBarHeight: 0, // 小程序顶部状态栏+导航栏高度
				menuButtonHeight: 0, // 小程序胶囊高度
				menuTop: 0, // 小程序胶囊top位置
				systemInfo: {},
				rpx: 0,
				navBarSafeArea: {
					// 小程序导航条安全区域（胶囊）
					left: 0,
					right: 0,
				},
			},
		};
	},
	computed: {
		isMp() {
			// #ifdef MP
			return true;
			// #endif
			return false;
		},
	},
	created() {
		// #ifdef MP
		// 获取状态栏高度
		const {
			screenWidth,
			statusBarHeight,
			windowWidth
		} = uni.getSystemInfoSync();
		this.mp.rpx = windowWidth / 750;
		this.mp.statusBarHeight = statusBarHeight;
		this.mp.systemInfo = uni.getSystemInfoSync()
		const {
			width,
			height,
			top,
			right
		} = uni.getMenuButtonBoundingClientRect(); // 胶囊的坐标
		// 计算导航栏的高度，此高度基于右上角菜单在导航栏位置垂直居中计算得到
		this.mp.menuTop = top
		this.mp.menuButtonHeight = height;
		this.mp.navBarHeight = height + (top - statusBarHeight) * 2;
		this.mp.topBarHeight = this.mp.statusBarHeight + this.mp.navBarHeight;
		this.mp.navBarSafeArea.right = (screenWidth - right) * 2 + width;
		// #endif
	},
};